<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="评语" prop="comments">
        <el-input
          v-model="queryParams.comments"
          placeholder="请输入评语"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="综合评分" prop="score">
        <el-input
          v-model="queryParams.score"
          placeholder="请输入综合评分"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评价时间" prop="commentTime">
        <el-date-picker clearable
          v-model="queryParams.commentTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择评价时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
         <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['order:evaluate:export']"
        >导出</el-button>
      </el-form-item>
    </el-form>



    <el-table  :data="evaluateList" >
      <el-table-column label="订单编号" prop="orderIdw" align="center" />
      <el-table-column label="服务内容" align="center" prop="serviceName" />
      <el-table-column label="评级者" align="center" prop="username" />
      <el-table-column label="星级" align="center">
        <template slot-scope="scope">
          <div>{{scope.row.score}}星</div>
        </template>
      </el-table-column>
      <el-table-column label="评价照片" align="center" prop="photo" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.photo" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="评价内容" align="center" prop="comments" />

      <el-table-column label="评价时间" align="center" prop="commentTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.commentTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>

    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>

import { listEvaluate, getEvaluate, delEvaluate, addEvaluate, updateEvaluate } from "@/api/order/evaluate";
export default {
  name: "Evaluate",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 评价的照片表格数据
      evaluateList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        evaluateId: null,
        photo: null,
        score: null,
        commentTime: null
      },

      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {


     getList() {

      listEvaluate(this.queryParams).then(response => {
        console.log(response.rows);
        this.evaluateList = response.rows;
        this.total = response.total;

      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        evaluateId: null,
        photo: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },



    /** 导出按钮操作 */
    handleExport() {
      this.download('order/image/export', {
        ...this.queryParams
      }, `image_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
